using System;
using System.Collections;
using System.Collections.Specialized;
using System.Runtime.InteropServices;
namespace BMC.ARSystem
{
	[ARStructTypeInfo(Name = "ARFieldInfoStruct", NumberOfMembers = 19u), ClassInterface, ComVisible(false), Guid("240c0fd9-1224-4e48-8159-b5821218aa3d"), ProgId("BMC.ARSystem.Field")]
	public abstract class Field
	{
		[Guid("9a09ee4d-9bcc-41ed-b45e-39a1931f0935")]
		public enum CoreFieldIds
		{
			AR_CORE_ENTRY_ID = 1,
			AR_CORE_SUBMITTER,
			AR_CORE_CREATE_DATE,
			AR_CORE_ASSIGNED_TO,
			AR_CORE_LAST_MODIFIED_BY,
			AR_CORE_MODIFIED_DATE,
			AR_CORE_STATUS,
			AR_CORE_SHORT_DESCRIPTION,
			AR_CORE_STATUS_HISTORY = 15
		}
		[Guid("5b24f829-fdc6-4e28-b360-14c3c19a2f5b")]
		public enum MemberFlags
		{
			FormName = 1,
			Id,
			Name = 4,
			Mapping = 8,
			FieldOption = 16,
			CreateMode = 32,
			DefaultValue = 64,
			Permissions = 128,
			Limit = 256,
			DisplayInstances = 512,
			HelpText = 1024,
			Owner = 2048,
			ChangeDiary = 4096,
			LastUpdateTime = 8192,
			LastModifiedBy = 16384,
			AuditOption = 32768,
			Properties = 65536,
			AssignedGroupList = 131072,
			AssignedName = 262144,
			NONE = 0,
			ALL = 262143
		}
		private string _formName;
		[ARStructMemTypeInfo(Name = "fieldId", Offset = 0u)]
		private uint _fieldId;
		[ARStructMemTypeInfo(Name = "fieldName", Offset = 1u)]
		private string _fieldName;
		[ARStructMemTypeInfo(Name = "timestamp", Offset = 2u)]
		private DateTime _timestamp;
		private FieldMapping _fieldMap;
		[ARStructMemTypeInfo(Name = "fieldOption", Offset = 5u)]
		private uint _fieldOption;
		[ARStructMemTypeInfo(Name = "createMode", Offset = 6u)]
		private uint _createMode;
		[ARStructMemTypeInfo(Name = "auditOption", Offset = 7u)]
		private uint _auditOption;
		[ARStructMemTypeInfo(Name = "defaultVal", Offset = 8u)]
		private object _defaultVal;
		[ARStructMemTypeInfo(Name = "permList", Offset = 9u)]
		private ArrayList _permList;
		[ARStructMemTypeInfo(Name = "assignedGroupList", Offset = 10u)]
		private ArrayList _assignedGroupList;
		[ARStructMemTypeInfo(Name = "limit", Offset = 11u)]
		private Limit _limit;
		[ARStructMemTypeInfo(Name = "dInstanceList", Offset = 12u)]
		private IDictionary _dInstanceList;
		[ARStructMemTypeInfo(Name = "owner", Offset = 13u)]
		private string _owner;
		[ARStructMemTypeInfo(Name = "lastChanged", Offset = 14u)]
		private string _lastChanged;
		[ARStructMemTypeInfo(Name = "helpText", Offset = 15u)]
		private string _helpText;
		[ARStructMemTypeInfo(Name = "changeDiary", Offset = 16u)]
		private DiaryList _changeDiary;
		[ARStructMemTypeInfo(Name = "objPropList", Offset = 17u)]
		private IDictionary _objPropList;
		[ARStructMemTypeInfo(Name = "assgnName", Offset = 18u)]
		private string _assgnName;
		private BitVector32 _modifyFlags;
		public string FormName
		{
			get
			{
				return this._formName;
			}
			set
			{
				if (this._formName == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 1);
				this._formName = value;
			}
		}
		public uint Id
		{
			get
			{
				return this._fieldId;
			}
			set
			{
				if (this._fieldId == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 2);
				this._fieldId = value;
			}
		}
		public uint FieldId
		{
			get
			{
				return this.Id;
			}
			set
			{
				this.Id = Convert.ToUInt32(value);
			}
		}
		public string Name
		{
			get
			{
				return this._fieldName;
			}
			set
			{
				if (this._fieldName == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 4);
				this._fieldName = value;
			}
		}
		public DateTime LastUpdateTime
		{
			get
			{
				return this._timestamp;
			}
		}
		public IDictionary Properties
		{
			get
			{
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 65536);
				return this._objPropList;
			}
			set
			{
				if (this._objPropList == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 65536);
				this._objPropList = value;
			}
		}
		public FieldMapping FieldMapping
		{
			get
			{
				return this._fieldMap;
			}
			set
			{
				if (this._fieldMap == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 8);
				this._fieldMap = value;
			}
		}
		public uint DataType
		{
			get
			{
				if (this is IntegerField)
				{
					return 2u;
				}
				if (this is RealField)
				{
					return 3u;
				}
				if (this is CharacterField)
				{
					return 4u;
				}
				if (this is DiaryField)
				{
					return 5u;
				}
				if (this is SelectionField)
				{
					return 6u;
				}
				if (this is DateTimeField)
				{
					return 7u;
				}
				if (this is DecimalField)
				{
					return 10u;
				}
				if (this is AttachmentField)
				{
					return 11u;
				}
				if (this is CurrencyField)
				{
					return 12u;
				}
				if (this is DateOnlyField)
				{
					return 13u;
				}
				if (this is TimeOnlyField)
				{
					return 14u;
				}
				if (this is TableField)
				{
					return 33u;
				}
				if (this is ColumnField)
				{
					return 34u;
				}
				if (this is TrimField)
				{
					return 31u;
				}
				if (this is ControlField)
				{
					return 32u;
				}
				if (this is PageField)
				{
					return 35u;
				}
				if (this is PageHolderField)
				{
					return 36u;
				}
				if (this is AttachmentPoolField)
				{
					return 37u;
				}
				if (this is ViewField)
				{
					return 42u;
				}
				return 0u;
			}
		}
		public uint FieldOption
		{
			get
			{
				return this._fieldOption;
			}
			set
			{
				if (this._fieldOption == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 16);
				this._fieldOption = value;
			}
		}
		public uint CreateMode
		{
			get
			{
				return this._createMode;
			}
			set
			{
				if (this._createMode == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 32);
				this._createMode = value;
			}
		}
		public uint AuditOption
		{
			get
			{
				return this._auditOption;
			}
			set
			{
				if (this._auditOption == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 32768);
				this._auditOption = value;
			}
		}
		public object DefaultValue
		{
			get
			{
				return this._defaultVal;
			}
			set
			{
				if (this._defaultVal == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 64);
				this._defaultVal = value;
			}
		}
		public ArrayList Permissions
		{
			get
			{
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 128);
				return this._permList;
			}
			set
			{
				if (this._permList == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 128);
				this._permList = value;
			}
		}
		public ArrayList AssignedGroupList
		{
			get
			{
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 131072);
				return this._assignedGroupList;
			}
			set
			{
				if (this._assignedGroupList == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 131072);
				this._assignedGroupList = value;
			}
		}
		public Limit Limit
		{
			get
			{
				return this._limit;
			}
			set
			{
				if (this._limit == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 256);
				this._limit = value;
			}
		}
		public IDictionary DisplayInstanceList
		{
			get
			{
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 512);
				return this._dInstanceList;
			}
			set
			{
				if (this._dInstanceList == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 512);
				this._dInstanceList = value;
			}
		}
		public string Owner
		{
			get
			{
				return this._owner;
			}
			set
			{
				if (this._owner == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 2048);
				this._owner = value;
			}
		}
		public string LastModifiedBy
		{
			get
			{
				return this._lastChanged;
			}
		}
		public string HelpText
		{
			get
			{
				return this._helpText;
			}
			set
			{
				if (this._helpText == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 1024);
				this._helpText = value;
			}
		}
		public DiaryList ChangeDiary
		{
			get
			{
				return this._changeDiary;
			}
			set
			{
				if (this._changeDiary == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 4096);
				this._changeDiary = value;
			}
		}
		public string AssignedName
		{
			get
			{
				return this._assgnName;
			}
			set
			{
				if (this._assgnName == value)
				{
					return;
				}
				this._modifyFlags = new BitVector32(this._modifyFlags.get_Data() | 262144);
				this._assgnName = value;
			}
		}
		public bool IsCoreField
		{
			get
			{
				return Field.IsCoreFieldId(this.Id);
			}
		}
		[ComVisible(false)]
		public BitVector32 MembersModified
		{
			get
			{
				return this._modifyFlags;
			}
			set
			{
				this._modifyFlags = value;
			}
		}
		public int MembersModifiedAsInt
		{
			get
			{
				return this._modifyFlags.get_Data();
			}
			set
			{
				this._modifyFlags = new BitVector32(value);
			}
		}
		public Field()
		{
			this._modifyFlags = new BitVector32(3);
		}
		internal Field(object[] rawData, Server server) : this()
		{
			this.FormName = (string)Util.GetAt(rawData, new int[]
			{
				3
			});
			this.Id = Convert.ToUInt32(Util.GetAt(rawData, new int[]
			{
				4
			}));
			this.Name = (string)Util.GetAt(rawData, new int[]
			{
				5
			});
			this.FieldMapping = FieldMapping.createInstance((object[])Util.GetAt(rawData, new int[]
			{
				6
			}), server);
			this.FieldOption = Convert.ToUInt32(Util.GetAt(rawData, new int[]
			{
				8
			}));
			this.CreateMode = Convert.ToUInt32(Util.GetAt(rawData, new int[]
			{
				9
			}));
			this.AuditOption = Convert.ToUInt32(Util.GetAt(rawData, new int[]
			{
				10
			}));
			this.DefaultValue = Util.ConvertFromARValue((object[])Util.GetAt(rawData, new int[]
			{
				11
			}), false, true);
			this.Permissions = ARTypeMgr.Instance.ArrayListFromVariant(Type.GetType("Unknown"), (object[])Util.GetAt(rawData, new int[]
			{
				12
			}), server);
			this.AssignedGroupList = ARTypeMgr.Instance.ArrayListFromVariant(Type.GetType("Unknown"), (object[])Util.GetAt(rawData, new int[]
			{
				13
			}), server);
			this.Limit = Limit.createInstance((object[])Util.GetAt(rawData, new int[]
			{
				14
			}), server);
			ARTypeMgr arg_1D3_0 = ARTypeMgr.Instance;
			Type arg_1D3_1 = typeof(HybridDictionary);
			string arg_1D3_2 = "System.Int32";
			int[] keyIndex = new int[1];
			this._dInstanceList = arg_1D3_0.BuildCustomDictionaryFromVariant(arg_1D3_1, arg_1D3_2, keyIndex, "BMC.ARSystem.DisplayInstance", new int[]
			{
				1
			}, (object[])Util.GetAt(rawData, new int[]
			{
				15,
				1
			}), server);
			this.HelpText = (string)Util.GetAt(rawData, new int[]
			{
				16
			});
			this._timestamp = Util.GetDateTime(Convert.ToUInt32(Util.GetAt(rawData, new int[]
			{
				17
			})));
			this.Owner = (string)Util.GetAt(rawData, new int[]
			{
				18
			});
			this._lastChanged = (string)Util.GetAt(rawData, new int[]
			{
				19
			});
			this.ChangeDiary = DiaryList.Decode((string)Util.GetAt(rawData, new int[]
			{
				20
			}));
			ARTypeMgr arg_2C4_0 = ARTypeMgr.Instance;
			Type arg_2C4_1 = typeof(HybridDictionary);
			string arg_2C4_2 = "System.Int32";
			keyIndex = new int[1];
			this.Properties = arg_2C4_0.BuildCustomDictionaryFromVariant(arg_2C4_1, arg_2C4_2, keyIndex, "ARValue", new int[]
			{
				1
			}, (object[])Util.GetAt(rawData, new int[]
			{
				21
			}), server);
		}
		public bool IsDataField()
		{
			return this.DataType > 0u && this.DataType <= 14u;
		}
		public bool ExistsOnView(uint vuiId)
		{
			return this.DisplayInstanceList.Contains((int)vuiId);
		}
		public override string ToString()
		{
			return string.Format("{0}({1})", this.Name, this.Id);
		}
		internal static Field createInstance(object[] rawData, Server server)
		{
			uint num = Convert.ToUInt32(Util.GetAt(rawData, new int[]
			{
				7
			}));
			uint num2 = num;
			switch (num2)
			{
			case 2u:
				return new IntegerField(rawData, server);
			case 3u:
				return new RealField(rawData, server);
			case 4u:
				return new CharacterField(rawData, server);
			case 5u:
				return new DiaryField(rawData, server);
			case 6u:
			case 8u:
				return new SelectionField(rawData, server);
			case 7u:
				return new DateTimeField(rawData, server);
			case 9u:
			case 15u:
			case 16u:
			case 17u:
			case 18u:
			case 19u:
			case 20u:
			case 21u:
			case 22u:
			case 23u:
			case 24u:
			case 25u:
			case 26u:
			case 27u:
			case 28u:
			case 29u:
			case 30u:
				break;
			case 10u:
				return new DecimalField(rawData, server);
			case 11u:
				return new AttachmentField(rawData, server);
			case 12u:
				return new CurrencyField(rawData, server);
			case 13u:
				return new DateOnlyField(rawData, server);
			case 14u:
				return new TimeOnlyField(rawData, server);
			case 31u:
				return new TrimField(rawData, server);
			case 32u:
				return new ControlField(rawData, server);
			case 33u:
				return new TableField(rawData, server);
			case 34u:
				return new ColumnField(rawData, server);
			case 35u:
				return new PageField(rawData, server);
			case 36u:
				return new PageHolderField(rawData, server);
			case 37u:
				return new AttachmentPoolField(rawData, server);
			default:
				if (num2 == 42u)
				{
					return new ViewField(rawData, server);
				}
				break;
			}
			return new UnknownField(rawData, server);
		}
		public static bool IsCoreFieldId(uint fieldId)
		{
			switch (fieldId)
			{
			case 1u:
			case 2u:
			case 3u:
			case 4u:
			case 5u:
			case 6u:
			case 7u:
			case 8u:
			case 15u:
				return true;
			}
			return false;
		}
	}
}
